import requests
class EmpManageApi(object):
    def add_emp(self,head_data,emp_data):
        resp=requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",headers=head_data,json=emp_data)
        return resp
    def query_emp(self,emp_id,emp_data):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/"+emp_id,headers=emp_data)
        return resp
    def modify_emp(self,head_data,emp_data):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/1568891872846295040",
                            headers=head_data,json=emp_data)
        return resp
    def del_emp(self,emp_id,head_data):
        resp = requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/"+emp_id,headers=head_data)
        return resp
if __name__ == '__main__':
    emp=EmpManageApi()
    head_data={"Authorization":"4ea31cf8-488d-4d11-a6e6-6393dd3bed37"}
    emp_data={"username": "旭旭宝宝","mobile": "15512216126","formOfEmployment": 1,"workNumber": "9527"}
    resp=emp.add_emp(head_data,emp_data)
    print(resp.json())

    emp_id = "1570682527885045760"
    resp1=emp.query_emp(emp_id,head_data)
    print("查询员工",resp1.json())

    headers ={"Content-Type": "application/json","Authorization": "e1438c1c-58e0-4efa-adb4-2db920768e43"}
